<template>
  <div class="box">
    <el-form
      :model="form"
      label-position="right"
      label-width="120px"
      :inline="false"
      class="demo-form-inline"
    >
      <el-form-item label="截止上报时间：">
        <el-input disabled v-model="form.reportTime" />
      </el-form-item>
      <el-form-item label="审查内容：">
        <el-input disabled type="textarea" :rows="7" v-model="form.releaseContent" />
      </el-form-item>
      <el-form-item label="附件:">
        <el-upload
          v-model:file-list="attachmentFile"
          ref="uploadRef"
          :limit="1"
          disabled
          :headers="headers"
          action="/fastDfs/file/upload"
          :on-preview="previewFile"
        >
          <el-button type="primary">点击上传</el-button>
        </el-upload>
      </el-form-item>
    </el-form>
  </div>
</template>
<script lang="ts">
import { type } from '@/utils/utils'
import { reactive } from 'vue'
import { useStore } from 'vuex'
export default {
  components: {},
  setup() {
    const store = useStore()
    const form = reactive(store.state.projectCenter.examineDetailForm)
    // let fileList = [] as any
    // if (form.filePath && form.fileName) {
    //   fileList = [
    //     {
    //       name: form.fileName,
    //       url: form.filePath,
    //     },
    //   ]
    // }
    let attachmentFile = []
    if (form.filePath.length > 0) {
      attachmentFile = type(form.filePath)
        ? JSON.parse(form.fileName).map((item, index) => {
            return {
              name: item,
              url: JSON.parse(form.filePath)[index],
            }
          })
        : []
    }
    console.log(attachmentFile, 'attachmentFile')
    const previewFile = (uploadFile) => {
      console.log(uploadFile, 'uploadFile')
      window.open(uploadFile.url)
    }
    const cookie = () => localStorage.getItem('token')
    return {
      form,
      attachmentFile,
      headers: {
        Authorization: 'Bearer ' + cookie(),
      },
      previewFile,
    }
  },
}
</script>
<style lang="scss" scoped>
.el-form-item__content {
  display: flex;
}
</style>
